package com.nbsaas.boot.product.rest.convert;

import com.nbsaas.boot.product.data.entity.ProductSkuSpecValue;
import com.nbsaas.boot.product.api.domain.response.ProductSkuSpecValueResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
/**
* 商品SKU规格值-实体对象转化成响应对象
*/

public class ProductSkuSpecValueResponseConvert  implements Converter<ProductSkuSpecValueResponse,ProductSkuSpecValue> {

    @Override
    public ProductSkuSpecValueResponse convert(ProductSkuSpecValue source) {
        ProductSkuSpecValueResponse  result = new  ProductSkuSpecValueResponse();
        BeanDataUtils.copyProperties(source, result);

                    try {
                        if(source.getSpecValue()!=null){
                            result.setSpecValueName(source.getSpecValue().getName());
                        }
                    } catch (Exception ignored) { }

                    if(source.getProductSku()!=null){
                        result.setProductSku(source.getProductSku().getId());
                    }

                    try {
                        if(source.getProductSku()!=null){
                            result.setProductSkuName(source.getProductSku().getName());
                        }
                    } catch (Exception ignored) { }

                    if(source.getSpecValue()!=null){
                        result.setSpecValue(source.getSpecValue().getId());
                    }
        return result;
    }

}

